Function Reference

_DateDiff

Returns the difference between 2 dates, expressed in the type requested.

#include <Date.au3>
_DateDiff($sType, $sStartDate, $sEndDate)

 

Parameters

$sType D = Difference in days between the given dates
M = Difference in months between the given dates
Y = Difference in years between the given dates
w = Difference in Weeks between the given dates
h = Difference in hours between the given dates
n = Difference in minutes between the given dates
s = Difference in seconds between the given dates
$sStartDate Input date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sEndDate Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"

 

Return Value

Success: Difference between the 2 dates.
Failure: 0
@Error: 0 = No error.
1 = Invalid $sType
2 = Invalid $sStartDate
3 = Invalid $sEndDate

 

Remarks

None.

 

Related

_DateAdd

 

Example


#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )